package com.example.carbon.dao;

import com.example.carbon.pojo.BomManager;
import com.example.carbon.pojo.dto.BomManagerDto;
import com.example.carbon.pojo.dto.MaterialBomVo;
import com.example.carbon.pojo.dto.PageLimit;
import com.example.carbon.pojo.vo.BomManagerVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BomManagerDao {

    boolean updateNewInfo(BomManagerDto bomManagerDto,int id);

    @Select("select id,name,product,model,specifications,unit,product_model,`describe` from bom_manager where id =#{id}")
    BomManager selectBomManagerById(int id);

    @Delete("delete from  bom_manager where id=#{id}")
    boolean delById(int id);

    @Insert("insert into  bom_manager(name,product,product_model,`describe`)" +
            " values (#{name},#{product},#{product_model},#{describe})")
    boolean insertNewInfo(BomManagerDto bomManagerDto );

    /**
     * 通过分页和名称来查询数据
     * @param pageLimit
     * @param name
     * @return
     */


    List<BomManagerVo> selectAllInfo(PageLimit pageLimit,String name);


    int countOfSelect(String name);

    /**
     * 通过id来获取物料档案的信息
     * @param id
     * @return
     */
    @Select("select material_info.id,m_name,m_type,m_specifications,m_unit,m_dosage,demo from bom_material_table,material_info" +
            " where bom_material_table.material_id=material_info.id and bom_material_table.bom_id=#{id}")
    List<MaterialBomVo> selectByBomId(int id);



}
